﻿(function ($) {
	var defaultOptions = {
		content: '#main-content',
		viewContent: '#view-content',
		socialPostUrl: null,
	};

	function init(options) {
		var opt = $.extend({}, defaultOptions, options);
		var $content = $(opt.content);
		var $viewContent = $(opt.viewContent);

		$('[id^="text-"]:not(":first")', $content).remove();
		$('[id^="text-"]', $content).append($viewContent.detach().show());
	}

	function initSocial(options) {
		var opt = $.extend({}, defaultOptions, options);
		var $viewContent = $(opt.viewContent);
		
		$('.b-share__link', $viewContent).click(function () {
			$.ajax({
				type: 'POST',
				url: options.socialPostUrl,
				data: {  },
				dataType: 'json',
				complete: function () {
					setInterval(function() { window.location.reload(true) }, 10000);
				},
			});
		});
	}


	$.extend({
		smarlyContentView: init,
		smarlyContentSocialView: initSocial,
	});
})(jQuery);